home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Cream of the Crop 22
/
Cream of the Crop 22.iso
/
bbs
/
pad321.zip
/
STRING.MH
< prev
next >
Wrap
Text File
|
1996-08-21
|
4KB
|
96 lines
// (C) 1995 Stefan Xenos
//
// This file defines various string manipulation functions. For more string-related
// operations, see the file char.mh, which includes operations between characters
// and strings.
//
// void stripRight (Ref string: theString, int: pos);
// void stripLeft (Ref string: theString, int: pos);
// void stripRightOf (Ref string: theString, char: toStripFrom);
// void stripNonNumeric (Ref string: theString);
// void stripStr (Ref string: sourceString, string: toStrip);
//
// string stripLeftf (string: theString, int: pos);
// string stripRightf (string: theString, int: pos);
// string stripRightOff (string: theString, char: toStripFrom);
// string stripNonNumericf (string: theString);
// string stripStrf (string: sourceString, string: toStrip);
//
// bool findAllChars (string: toSearch, string: charsToSearchFor);
// bool findAnyChars (string: toSearch, string: charsToSearchFor);
//
// void stringInit ();
// bool stringToken (string: token, string: params);
//
#ifndef __STRING_MH
#define __STRING_MH
//#ifndef __CHAR_MH
//#include "char.mh"
//#endif
// Erases everything after a particular position in a string. The position is
// given by pos. The character at pos is deleted as well. The original string
// is modified.
void stripRight (Ref string: theString, int: pos) {
theString := substr (theString, 1, pos - 1);
}
// Erases everything after a particular position in a string. The position is
// given by pos. The character at pos is deleted as well. Returns the new string
// without modifying the original string.
//string stripRightf (string: theString, int: pos) {
// stripRight (theString, pos);
// return theString;
// }
// Erases everything before a particular position in a string. The position is
// given by pos. The character at pos is deleted as well. The original string
// is modified.
//void stripLeft (Ref string: theString, int: pos) {
// theString := substr (theString, pos + 1, strlen (theString) - pos);
// }
// Erases everything before a particular position in a string. The position is
// given by the parameter pos. The character at pos is deleted as well. The
// new string is returned without modifying the original string.
//string stripLeftf (string: theString, int: pos) {
// stripLeft (theString, pos);
// return theString;
// }
// Searches for the first occourance of stripChar in the given string, then
// erases the remainder of the string - including stripChar. This is useful
// for eliminating comments from the end of lines in input files. The original
// string is modified.
void stripRightOf (Ref string: theString, char: stripChar) {
int: idx;
idx := stridx (theString, 1, stripChar);
if (idx) theString := substr (theString, 1, idx - 1);
}
// Same as above, but does not modify the original string.
//string stripRightOff (string: theString, char: stripChar) {
// stripRightOf (theString, stripChar);
// return theString;
// }
// Same as above, but the original string is not modified - the new string
// is returned by the function.
//string stripStrf (string: theString, string: s) {
// stripStr (theString, s);
// return theString;
// }
#endif